from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

class ItemSKUBase(BaseModel):
    item_name: str
    cleaned_name: Optional[str] = None
    item_brand: Optional[str] = None
    item_specs: Optional[str] = None
    item_price: Optional[float] = None
    base_price: Optional[float] = None
    base_unit: Optional[str] = None
    base_num: Optional[float] = None
    package_type: Optional[str] = None
    item_classification: Optional[str] = None
    item_img: Optional[str] = None
    sku: Optional[str] = None
    is_handled: Optional[bool] = False
    human_tag: Optional[bool] = None

class ItemSKUCreate(ItemSKUBase):
    pass

class ItemSKUUpdate(ItemSKUBase):
    id: int

class ItemSKU(ItemSKUBase):
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

# 新增：自动标注请求和响应模型
class AutoLabelRequest(BaseModel):
    item_name: Optional[str] = None
    item_ids: Optional[List[int]] = None
    batch_mode: bool = False

class AutoLabelResponse(BaseModel):
    item_brand: Optional[str] = None
    item_specs: Optional[str] = None
    cleaned_name: Optional[str] = None
    base_unit: Optional[str] = None
    package_type: Optional[str] = None
    confidence: Optional[float] = None
    message: str

class BatchAutoLabelResponse(BaseModel):
    results: List[AutoLabelResponse]
    total: int
    success_count: int
    error_count: int
    message: str 